package com.feather.common.converter.simple.fieldassignment;

import java.lang.reflect.Field;

import com.feather.common.converter.FieldAssignment;
import com.feather.common.util.ClassUtil;

/**
 * @author flogyin
 */
public class StringArray_Character implements FieldAssignment {
	@Override
	public Object assign(Object value, Object obj, Field field) {
		Character c = null;
		String[] strArray = (String[]) value;
		if (strArray != null && strArray.length > 0) {
			String str = strArray[0];
			if (str != null && str.length() > 0)
				c = Character.valueOf(str.charAt(0));
		}
		if (c == null && boolean.class.getName().equals(field.getType().getName())) {
			c = 0;
		}

		ClassUtil.set(obj, field, c);
		return null;
	}
}
